import BuffUtil from '@/BuffUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 魔甲术
 **/
export default class SS_MagicArmor extends AbilityBase {
    static instance: SS_MagicArmor;
    buffType: AppBuffType = {
        id: 'buff_SS_MagicArmor',
        art: this.art,
        name: this.abilityName,
        ubertip: '增加魔抗与法术吸血',
        dur: 20,
        targetAttach: 'chest',
        targetArt: '抗壳2\\sem_kang_qiao_2.mdx',
        attribute: {
            法术吸血: 0.2,
        },
    };
    constructor(id: string = 'Amjs') {
        super(id);
        SS_MagicArmor.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        // let buff = BuffUtil.addBuff(target, this.buffType.id, source);
        let lv = this.getAbilityLevel(source);
        // buff.attribute.附加魔抗 = (UnitCommon.取总智力(buff.getCaster()) + UnitCommon.取法强(buff.getCaster())) * lv * 0.5 + 20;
        BuffCommon.addBuff({
            target,
            caster: source,
            buffTypeId: this.buffType.id,
            ablityId: this.id,
            attribute: { 附加魔抗: (UnitCommon.取总智力(source) + UnitCommon.取法强(source)) * lv * 0.5 + 20 },
        });
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
